package com.cyys.modules.generator.model;

import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.SqlCondition;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.cyys.common.model.BaseBean;
import com.cyys.common.utils.StringUtil;
import com.cyys.modules.core.sysParam.ParamBasicUtil;
import com.cyys.modules.core.sysParam.ParamConstants;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;

@Data
@TableName("generator_field")
public class GeneratorField extends BaseBean {

	private String tableId;  //表编号

	@TableField(condition = SqlCondition.LIKE)
	private String columnName;  //数据库列名称

	private String columnType;  //数据库列类型

	private Integer columnLength1;  //列长度1

	private Integer columnLength2;  //列长度2

	private String columnComment;  //java字段注释

	private String fieldName;  //java转换字段名称

	private String fieldType;  //java转换字段类型

	private Long ordinalPosition; //列排序

	private String inputType;  //0:保存编辑时不出现input，1:文本框；2:日期框;3:单文件选择;4:多文件选择;5:系统参数选择框

	@TableField(updateStrategy = FieldStrategy.IGNORED)
	private String paramName;  //系统参数名称

	private String listShow;//list页面是否展示

	private String required; //是否必填0：不判断，1：required 2:number 3： phone 4；email；5：url；6：date，7：identity

	private String isQuery;  //是否查询列

	@JsonIgnore
	public String getInputTypeName() {
		if(StringUtil.isNotEmpty(inputType))
			return ParamBasicUtil.getParamBasicTypeMap().get(ParamConstants.GENERATOR_INPUT_TYPE).get(inputType);
		return "";
	}

	@JsonIgnore
	public String getListShowName() {
		if(StringUtil.isNotEmpty(listShow))
			return ParamBasicUtil.getParamBasicTypeMap().get(ParamConstants.YES_NO).get(listShow);
		return "";
	}

	@JsonIgnore
	public String getRequiredName() {
		if(StringUtil.isNotEmpty(required))
			return ParamBasicUtil.getParamBasicTypeMap().get(ParamConstants.GENERATOR_REQUIRED).get(required);
		return "";
	}

	@JsonIgnore
	public String getIsQueryName() {
		if(StringUtil.isNotEmpty(isQuery))
			return ParamBasicUtil.getParamBasicTypeMap().get(ParamConstants.YES_NO).get(isQuery);
		return "";
	}


}
